package com.snake.design.pe.factory;

/**
 * 
 * @author fengx00 1.抽象工厂就是定义一个抽象类然后搞几个抽象方法返回某些抽象对象或者接口
 *         2.搞一个对象取实现抽象方法即可3.抽象方法可以是具体的类也可以是接口
 */
public abstract class AbstractFactory {
	public abstract A1 createA1();

	public abstract A2 createA2();

	public abstract A3 createA3();

	public abstract A4 createA4();

	public static void main(String[] args) {
		AbstractFactory a = new D();
		a.createA1().createHero();
		a.createA2().createHero();
		a.createA3().createHero();
		a.createA4().createHero();
	}
}

class A1 {
	public void createHero() {
		System.out.println("创建一个火女");
	}
}

class A2 {
	public void createHero() {
		System.out.println("创建一个影魔");
	}
}

interface A3 {
	public void createHero();
}

interface A4 {
	public void createHero();
}

class A3Impl implements A3 {

	@Override
	public void createHero() {
		System.out.println("创建一个韩信");

	}

}

class A4Impl implements A4 {

	@Override
	public void createHero() {
		System.out.println("创建一个冰女");
	}
}

class D extends AbstractFactory {

	@Override
	public A1 createA1() {
		return new A1();
	}

	@Override
	public A2 createA2() {
		return new A2();
	}

	@Override
	public A3 createA3() {
		return new A3Impl();
	}

	@Override
	public A4 createA4() {
		return new A4Impl();
	}
}
